Skip to content

KubeNodeKubeletV1 added - #30

Open
bx9001 wants to merge 7 commits into
Checkmk:masterfrom
bx9001:CMK-36238-node-kubelet
Open

KubeNodeKubeletV1 added#30
bx9001 wants to merge 7 commits into
Checkmk:masterfrom
bx9001:CMK-36238-node-kubelet

Conversation

@bx9001

@bx9001 bx9001 commented Aug 11, 2026

Copy link
Copy Markdown

CMK-36238

@bx9001
bx9001 marked this pull request as ready for review August 11, 2026 15:45
@bx9001
bx9001 marked this pull request as draft August 13, 2026 08:24
@bx9001
bx9001 marked this pull request as ready for review August 17, 2026 16:56

@relrod relrod left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably the most important thing this is missing is RBAC. The scrape won't actually work with out it, we need to add nodes/healthz in charts/cmk-rustik/templates/metrics-fetcher/clusterrole.yaml

match self {
Self::KubeletStatsSummary(bytes) => bytes.clone(),
Self::KubeletHealth { health, .. } => {
Bytes::from(serde_json::to_vec(health).expect("KubeletHealth always serializes"))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's avoid .expect() here (if there's an issue serializing, we'll panic otherwise).

One option would be to make Payload::KubeletHealth look identical in structure to Payload::CheckmkLinuxAgent. Then do the serialization to JSON in your scrape(). Then this ends up looking just like the it does for the Self::CheckmkLinuxAgent case below.

name: "NODE_NAME".to_string(),
source: e,
})?;
let token = std::fs::read_to_string("/var/run/secrets/kubernetes.io/serviceaccount/token")?;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer tokio::fs::read_to_string().await? here

let token = std::fs::read_to_string("/var/run/secrets/kubernetes.io/serviceaccount/token")?;

debug!("fetching Kubelet /healthz");
let health = match self

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd simplify this a bit by storing the intermediate result (like kubelet_stats_summary does) and doing the match below it.

i.e.

let response = self.scrape_client.....send().await;
match response {...}

I'd also add a some logging (maybe pull the url into a variable and pass that in the log too):

        let url = format!("https://{node_ip}:10250/healthz");
        let response = ...;
        let status = response.status();
        if status == StatusCode::OK {
            debug!(status = %response.status(), url, "kubelet healthz scrape complete");
        } else {
            warn!(status = %response.status(), url, "kubelet healthz scrape returned non-OK status");
        }

@relrod relrod left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have maybe suggested having this be two separate PRs: One for ingest (get the data in from metrics-fetcher, chart changes, etc) and one for emission (everything under section/, piggyback/), just so it's easier to reason about.

But it's fine if you don't want to now, since it is already pretty close to done.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a good pattern to establish. I used it as a basis for #43 to suggest doing similar for the system agent output cache.

If #43 lands, I would recommend following that same approach here, a newtype pattern with a private member, and having get() return the whole Arc.

relrod added a commit that referenced this pull request Aug 18, 2026
Rather than store a direct HashMap in Snapshot, newtyping it lets us
avoid exposing a mutable structure from the snapshot.

And as we are going to have more of these kinds of data sources (#30),
it is better to establish a pattern now.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants